﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Decisions.HL7.Parser
{
    public class ParserRegistry
    {
        //private static ParserRegistry INSTANCE = new ParserRegistry();

        private static Dictionary<Type, DataParser> REGISTERED_PARSERS = new Dictionary<Type, DataParser>();

        public static object RunParser(Type dataType, string parseableText)
        {
            DataParser parser = REGISTERED_PARSERS[dataType];
            if (parser != null)
            {
                return parser.Parse(parseableText);
            }
            return null;
        }

        public static bool ParserFor(Type type)
        {
            return REGISTERED_PARSERS.ContainsKey(type);
        }


        private ParserRegistry()
        {

        }
    }
}
